const modulesFiles = require.context('./children', true, /.js$/)

const modules = modulesFiles.keys().reduce((modules, modulePath) => {
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
  const value = modulesFiles(modulePath)
  modules[moduleName] = value.default
  return modules
}, {})

export default {
  install(Vue) {
    Object.keys(modules).forEach(key => {
      Vue.directive(key, modules[key])
    })
  },
}
